<?php
function main($args){
    file_put_contents(dirname(__FILE__).'/files/'.md5($args->url).'.html',$args->contents);
    if(rand(0,1)){
        $args->agent->addUrls(
            array(
                'http://www.google.com/'.rand(1,5),
                'http://www.vancl.com/'.rand(1,5),
            ),rand(10000,40000)
        );
    }
    return true;

    #################  do something, like this ##################
    # 1. Save html content to file. like this
    file_put_contents('./files/'.md5($args->url).'.html',$args->contents);

    # 2. Different ticket corresponds to a different approach. like this
    switch($args->ticket){
        case 1: $urls = getItems($contents);     break;
        case 2: $urls = getContents($contents);  break;
    }

    # 3. Call $agent_obj->addUrls(array $urls, $tecket) to add it. like this
    $pagination_url = 1;
    $item_url       = 2;
    $args->agent->addUrls(
        array(
            'http://www.google.com/search?q=php&start=10&sa=N',
            'http://www.google.com/search?q=php&start=20&sa=N'
        ),$pagination_url
    );
    $args->agent->addUrls(
        array(
            'http://www.php.net',
            'php.net/downloads.php',
        ),$item_url
    );
    #################  do something, like this ##################
}
